const app = getApp()
let ServiceUrl = app.globalData.ServiceUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    empty: false,
    monthGetMoney: 0,
    orderMonthNum: 0,
    user_id: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    let that = this
    that.setData({user_id: options.user_id})
    that.request(options.user_id);
  },
request: function(user_id){
  let that = this
  wx.request({
    url: ServiceUrl + 'getEmployeeInfo',
    data: {user_id: user_id},
    //data: {user_id: 2},
    method:"get",
    success: function(res){
      console.log(res)
      if(res.data.state == 200){
        that.setData({
          listArr:res.data.orderList,
          orderMonthNum:res.data.orderMonthNum,
          monthGetMoney:res.data.monthGetMoney
        })
      }else{
        that.setData({
          empty: true
        })
      }
    },
    fail: function(){
      wx.showModal({
        title:"提示",
        content:"发送请求失败",
        showCancel: false,
        confirmColor: 'skyblue'
      })
    }
  })
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    let that = this
    let user_id= that.data.user_id
    
    wx.stopPullDownRefresh({
      success: (res) => {
        that.request(user_id);
      },
    },3000)
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})